package com.cqupt.tr.edgenode.utils;

import api.EdgeRequest;
import api.EdgeRequestWithAccount;
import api.EdgeSign;

import java.text.SimpleDateFormat;
import java.util.HashMap;

public class HandleHttp {

    public static String getHandleMessage(EdgeRequestWithAccount edgeRequest){
        try {
            HashMap<String,Object> hm = new HashMap();
            hm.put("account",edgeRequest.getAccount());
            EdgeRequest request = new EdgeRequest(edgeRequest.getHandle(),edgeRequest.getIndexs(),edgeRequest.getTypes());
            hm.put("jsonData",ObjectJsonTransFunction.toJsonStr(request));
            EdgeSign edgeSign = new EdgeSign();
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String predate = format.format(System.currentTimeMillis());
            edgeSign.setTimestamp(predate);
            edgeSign.setSign("");
            hm.put("sign",ObjectJsonTransFunction.toJsonStr(edgeSign));
            HttpClientUtil.httpPostRequest("https://api.gdsinsing.com/safety/api/query-identifier", hm);
        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

}
